function babelConfig() {
  const isVue = process.env.mode == "vue";
  var config = {};

  config["presets"] = [
    [
      "@babel/env",
      {
        targets: {
          browsers: [">0.25%", "not ie 11", "not op_mini all"],
        },
      },
    ],
  ];

  config["plugins"] = [
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-proposal-class-properties",
    [
      "@babel/plugin-transform-runtime",
      {
        corejs: 3,
      },
    ],
    "@babel/plugin-transform-async-to-generator",
  ];

  // 判断环境
  if (isVue) {
    config["plugins"].push([
      "component",
      {
        libraryName: "element-ui",
        styleLibraryName: "theme-chalk",
      },
    ]);
  } else {
    config["presets"].push("@babel/preset-react", "@babel/preset-typescript");
    config["plugins"].push([
      "import",
      {
        libraryName: "antd",
        libraryDirectory: "es",
        style: "true",
      },
    ]);
  }

  return config;
}

module.exports = babelConfig();
